// Google Analytic埋点
import { getEnv } from '~/utils';
export const useReport = (category: string, action: string, label: string) => {
    if (process.server) return;
    const gtag = useGtag();
    const displayUserId =
        JSON.parse(window.localStorage.getItem('userInfo') || '{}')?.displayUserId || '空';
    const appVersion = window.sessionStorage.getItem('version') ?? '未知';
    const appDeviceIdId = window.localStorage.getItem('deviceId') ?? '未知';
    const _label = `${label}${`+用户ID:${displayUserId}`}+version:${appVersion}+deviceId:${appDeviceIdId}`;
    const isProd = getEnv() === 'PROD';
    if (isProd) {
        gtag('event', category, {
            event_category: category,
            event_action: action,
            event_label: _label,
        });
    } else {
        console.log(
            `🥭%c埋点上报: \r\n📔category: ${category}\r\n🤏action: ${action}\r\n📄label: ${_label}`,
            'color: #339966'
        );
    }
};
